home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '91 / Hacks '91 / OkOkOk / OkOkOk.a < prev    next >
Encoding:
Text File  |  1991-06-20  |  2.2 KB  |  122 lines  |  [TEXT/MPS ]

  1.     include    'Traps.a'
  2.     include    'SysEqu.a'
  3.     
  4. ModalDialogTrapNum    equ    $191
  5.  
  6. OkOkOkThreshold    equ    120
  7.  
  8.  
  9. OkOkOk    main
  10.  
  11.     move.l    a0,-(sp)            ; save a handle to ourselves
  12.     _DetachResource            ; use handle to us that we saved earlier
  13.  
  14.     move.w    #ModalDialogTrapNum,d0
  15.     _GetTrapAddress
  16.     lea    realAlertAddress,a1
  17.     move.l    a0,(a1)            ; save a copy of the real _ModalDialog
  18.     
  19.     move.w    #ModalDialogTrapNum,d0
  20.     lea    MyModalDialog,a0
  21.     _SetTrapAddress
  22.  
  23.     lea    oldJGNEFilter,a0
  24.     move.l    JGNEFilter,(a0)
  25.     lea    MyGNE,a0
  26.     move.l    a0,JGNEFilter
  27.     
  28.     rts
  29.  
  30. MyModalDialog:
  31.     jsr    ResetClickTime
  32.  
  33.     move.l    (sp)+,a0            ; get real return address so we can end around
  34.  
  35.     move.l    (sp)+,d0            ; pull off params
  36.     move.l    (sp)+,d1
  37.  
  38.     move.l    a0,-(sp)            ; shove on real return address
  39.  
  40.     move.l    d1,-(sp)            ; re-stack parameters
  41.     move.l    d0,-(sp)
  42.  
  43.     lea    MyGNEPatchEnable,a0        ; enable patch
  44.     addq.l    #1,(a0)
  45.  
  46.     move.l    realAlertAddress,a0        ; invoke the previous jGNEFilter proc
  47.     jsr    (a0)
  48.  
  49.     lea    MyGNEPatchEnable,a0        ; “disable” patch
  50.     subq.l    #1,(a0)
  51.  
  52.     rts                ; bounce back to real caller
  53.  
  54.  
  55. ResetClickTime:
  56.     clr.l    -(sp)            ; Save New Epoch
  57.     _TickCount
  58.     move.l    (sp)+,d0
  59.     lea    alertCalledTicks,a0
  60.     move.l    d0,(a0)
  61.     rts
  62.  
  63.  
  64. MyGNE:
  65.     move.l    d0,-(sp)            ; save d0
  66.     
  67.     move.l    MyGNEPatchEnable,d0        ; Are we enabled?
  68.     cmp.l    #0,d0
  69.     beq.s    justGNE            ; no, skip our hack
  70.     
  71.     move    evtNum(a1),d0
  72.     cmp.l    #mButDwnEvt,d0
  73.     blt.s    CheckForTimeout
  74.     cmp.l    #autoKeyEvt,d0
  75.     bgt.s    CheckForTimeOut
  76.  
  77.     jsr    ResetClickTime        ; The user did something so reset the timer
  78.     bra.s    justGNE            ; then fall through and keep going
  79.  
  80. CheckForTimeout:    
  81.     move.l    evtTicks(a1),d0        ; compare time against start time
  82.     sub.l    alertCalledTicks,d0
  83.     cmp.l    #OkOkOkThreshold,d0
  84.     blt.s    justGNE
  85.  
  86.     move.w    #keyDwnEvt,evtNum(a1)    ; make the event a return!
  87.     move.l    #13,evtMessage(a1)
  88.  
  89.     move.l    (sp)+,d0
  90.     
  91.     move.l    #-1,d0
  92.     move.w    d0,4(sp)
  93.  
  94.     bra.s    jumpBack
  95.  
  96. justGNE:
  97.     jsr    UpdateProgress
  98.     move.l    (sp)+,d0            ; restore old d0
  99.  
  100. jumpBack:                    ; Jump off to the “real” jGNEFilter Proc
  101.     move.l    oldJGNEFilter,a0
  102.     jmp    (a0)
  103.  
  104.  
  105. UpdateProgress:
  106.  
  107. ; Do some useful HI interaction to let the user know how much time
  108. ; they have left…
  109. ;
  110. ; NOT!
  111.     rts
  112.  
  113. alertCalledTicks    dc.l    0
  114. MyGNEPatchEnable    dc.l    0
  115. oldJGNEFilter    dc.l    0
  116. realReturnAddress    dc.l    0
  117. realAlertAddress    dc.l    0
  118.  
  119.     endmain
  120.     
  121.     end
  122.